package cn.ph.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * 3.启动流程实例:  前提是已经完成了流程的部署工作
 * 影响的表:
 *
 */
public class ActivitiStart {
  public static void main(String[] args) {
    //1. 创建ProcessEngine对象
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    // 2. 获取RunTimeService
    RuntimeService runtimeService =processEngine.getRuntimeService();
    //3. 创建流程实例: 根据流程定义key启动流程
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_1");
    //4. 输出实例的相关信息
    System.out.println("流程定义id："+processInstance.getProcessDefinitionId()); //myProcess_1:1:4
    System.out.println("流程实例id：" + processInstance.getId()); //2501
    System.out.println("当前活动Id："+processInstance.getActivityId());//null
  }
}
